<template>
<div class="app-container">
    <el-card style="width:60%">
            <el-form :model="form" ref="form">
            <el-form-item label="发送邮箱"  prop="send_email" :rules="[{ required: true, message: '发送邮箱不能为空'}]">
            <el-input    placeholder="请输入发送邮箱" v-model="form.send_email" clearable></el-input>
            </el-form-item>
          <el-form-item label="邮箱密码"  prop="password" :rules="[{ required: true, message: '邮箱密码不能为空'}]">

            <el-input      placeholder="请输入邮箱密码" v-model="form.password" clearable></el-input>
            </el-form-item>


          <el-form-item label="发送服务器"  prop="sending_server" :rules="[{ required: true, message: '发送服务器不能为空'}]">
            <el-input   placeholder="请输入"  v-model="form.sending_server" clearable></el-input>
            </el-form-item>

              <el-form-item label="发送服务器 无ssl 端口"  prop="sending_server_no_ssl" :rules="[{ required: true, message: '端口不能为空'}]">
            <el-input  placeholder="请输入"  v-model="form.sending_server_no_ssl" clearable></el-input>
            </el-form-item>

             <el-form-item label="发送服务器 有ssl 端口"  prop="sending_server_ssl" :rules="[{ required: true, message: '端口不能为空'}]">
            <el-input  placeholder="请输入"  v-model="form.sending_server_ssl" clearable></el-input>
            </el-form-item>

             <el-form-item label="接收服务器"  prop="receiving_server" :rules="[{ required: true, message: '接收服务器不能为空'}]">
            <el-input   placeholder="请输入"  v-model="form.receiving_server" clearable></el-input>
            </el-form-item>

            <el-form-item label="接收服务器 无ssl 端口"  prop="receiving_server_no_ssl" :rules="[{ required: true, message: '端口不能为空'}]">
            <el-input   placeholder="请输入"  v-model="form.receiving_server_no_ssl" clearable></el-input>
            </el-form-item>


            <el-form-item label="接收服务器 有ssl 端口"  prop="receiving_server_ssl" :rules="[{ required: true, message: '端口不能为空'}]">
            <el-input  placeholder="请输入"  v-model="form.receiving_server_ssl" clearable></el-input>
            </el-form-item>


        </el-form>

            <el-button type="primary"  @click="updateData()" style="float:right;margin-bottom:10px;">保存</el-button
            >

        </el-card>

  </div>

</template>


<script>

import { Message } from "element-ui";
import {
  getEmailServer,
  EditEmailServer
} from "@/app/api/system";


export default {
  name: "emailServer",
  data() {
    return {
        form:{
          id:'',
          send_email:'',
          password:'',
          sending_server:'',
          receiving_server:'',
          receiving_server_no_ssl:'',
          receiving_server_ssl:'',
          sending_server_no_ssl:'',
          sending_server_ssl:''
        },
    }
  },
   created() {
    this.getList();
  },
  methods:{
      getList(){
        getEmailServer().then((res) =>{
          this.form = res.data
          }).catch((error) => {
            console.log('getEmailServer error', error)
          })
      },

      updateData(){
           EditEmailServer(this.form)
              .then((res) => {
                if (res.code == '00000') {
                  Message({
                    message: '保存成功',
                    type: 'success',
                    duration: 5 * 1000
                  })

                  this.getList();
                }
              }).catch((error) => {
                console.log('EditEmailServer error', error)
              })
      }

  }

}




</script>


<style scoped>

.el-input {
    width:80%;
}

</style>
